package com.yorge.client;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class PaymentClientFallbackFactory implements FallbackFactory<PaymentClient> {
    @Override
    public PaymentClient create(Throwable throwable) {
        // 这里可以获取到降级的异常信息
        log.info("异常信息为：{}",throwable.getMessage());

        return new PaymentClient() {
            @Override
            public String paymentInfo_OK(Integer id) {
                return "paymentInfo_OK 线程池："+Thread.currentThread().getName()+"   系统繁忙, 请稍候再试  ,id：  "+id+"\t"+"哭了哇呜";
            }

            @Override
            public String paymentInfo_TimeOut(Integer id) {
                return "paymentInfo_TimeOut 线程池："+Thread.currentThread().getName()+"   系统繁忙, 请稍候再试  ,id：  "+id+"\t"+"哭了哇呜";
            }
        };
    }
}
